package com.songwp.common;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName: MybatisPlusConfig
 * @Description:
 * @Author: songwp
 * @Date: 15:57 2022/4/18
 **/
@Configuration
@MapperScan("com.songwp.mapper")  //官方文档说要加MapperScan
//主要是扫描到mapper包下的接口交给spring管理，我这里在启动类上添加过了，这里就不加了
public class MybatisPlusConfig {
    /**
     * mybatis-plus自带的分页插件
     * @return
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
